import 'package:after_sale_plugin/r.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lx_widgets_library/lx_widgets_library.dart';

import '../../models/order_model.dart';

class CheckVehicleErrorResultItem extends StatelessWidget {
  // 工单数据
  Rx<ReportOrderInfo> reportOrderInfo = ReportOrderInfo.fromMap({}).obs;

  // 最大宽度
  final double? maxWidth;

  CheckVehicleErrorResultItem({
    super.key,
    required this.reportOrderInfo,
    this.maxWidth,
  });

  @override
  Widget build(BuildContext context) {
    return reportOrderInfo.value.diagnosis.value.descriptions.value == null ||
            reportOrderInfo.value.diagnosis.value.descriptions.value?.isEmpty ==
                true
        ? Padding(
            padding: EdgeInsets.only(top: CONTENT_MARGIN),
            child: Align(
              alignment: Alignment.centerLeft,
              child: LxText(
                AppLanguageUtil.to.vehicleNoErrorMessagePrompts,
                color: Colors.white,
                fontWeightEnum: LxFontWeightEnum.bodyLarge,
              ),
            ),
          )
        : Column(
            children: [
              const SizedBox(height: 16),
              Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Image.asset(
                    R.err_png,
                    package: PACKAGE_NAME,
                    width: 24,
                  ),
                  const SizedBox(width: 5),
                  SizedBox(
                    width: (maxWidth ?? screenWidth - 4 * CONTENT_MARGIN) - 30,
                    child: LxText(
                      reportOrderInfo.value.diagnosis.value.url.endsWith(".bin")
                          ? AppLanguageUtil
                              .to.vehicleErrorMessagePromptsLogUpload
                          : AppLanguageUtil.to.vehicleErrorMessagePrompts,
                      color: const Color(0xFFD32029),
                      fontWeightEnum: LxFontWeightEnum.bodyLarge,
                    ),
                  )
                ],
              )
            ],
          );
  }
}
